package milu.report;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;

public class SimpleReporter implements Reporter {

	private final List<Report> reports = new ArrayList<Report>();

	@Override public void receive(Report report) {
		reports.add(report);
	}

	@Override public String reportAsString() {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		int count = 0;
		for (Report r : reports) {
			pw.println();
			pw.println("-----------------------------------");
			pw.println("Bericht Nr. " + ++count);
			pw.print(r.asString());
		}
		pw.close();
		return sw.toString();
	}

}
